<?php

$GLOBALS['autoloadFolders'] = array();

function addAutoloadFolder($folder) {
    $GLOBALS['autoloadFolders'][] = $folder;
}

function __autoload($classname) {

    # Look in these folders for classes we need
    $folders = array(
        '',
        $GLOBALS['libaryPath'],
        $GLOBALS['libaryPath'].'database/',
        $GLOBALS['libaryPath'].'cronbjob/',
        $GLOBALS['libaryPath'].'engines/',
        $GLOBALS['libaryPath'].'panels/',
        $GLOBALS['libaryPath'].'components/',
    );

    $folders = array_merge($GLOBALS['autoloadFolders'], $folders);

    foreach($folders as $folder) {

        if(file_exists($folder.$classname.'.class.php')) {
            include($folder.$classname.'.class.php');
        }

    }

}
?>
